#include <iostream>
using namespace std;
#include <set>

// 做一个仿函数
class MyCom
{
public:
    bool operator()(int a, int b)
    {
        return rand()%2;
    }
};

void printSet(const set<int, MyCom> s)
{
    for (set<int>::const_iterator it = s.begin(); it != s.end(); ++it)
    {
        cout << (*it) << " ";
    }
    cout << endl;
}

bool myComp(int v1, int v2)
{
    rand();
    return v1 > v2;
}

void test01()
{
    set<int, MyCom> s1;
    for (int i = 0; i < 100; ++i)
    {
        s1.insert(rand());
    }
    s1.insert(100);
    printSet(s1);
    /*
    set<int>::iterator it = s1.find(3);
    cout << (it == s1.end()) << endl; // 与end相同，没找到，相同，找到

    cout << s1.count(1) << endl; // 数键的个数，0没有1有
    cout << s1.count(100) << endl;

    // set的返回值
    pair<set<int>::iterator, bool> ret = s1.insert(123);
    cout << ret.second << endl;
    ret = s1.insert(123);
    cout << ret.second << endl;*/
}

int main()
{
    test01();
}
